//
//  ReissueLetterBean.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/3/24.
//

import Foundation
//补发来信
class ReissueLetterBean : Codable {
    private var timeKey: String? = nil
    var time: Int64? = nil
    var title: String? = nil
    var read: Bool? = nil // 是否读取日记
    var desc: String? // 描述-也就是执行命令
    
    // 是否需要记忆，当为true的时候，就是需要关联记忆，如果没有开启记忆注入，那么这条补发就失效，常用于年度总结，月度总结之类的
    var memory: Bool? = nil
    var versionIos: Int? = nil // 最低版本号
    var count: Int? = nil
    var createLessThan: Int? = nil // 注册天数不能少于
    
    func getCount()->Int {
        return count ?? Int.max
    }
    
    func getCreateLessThan()->Int {
        return createLessThan ?? 10
    }
    
    func getKey() -> String? {
        guard let timeKey = timeKey, !timeKey.isEmpty else {
            return nil
        }
        if timeKey == "UUID" {
            return UUID().uuidString
        }
        return timeKey
    }
    
    func getTime() -> Int64 {
        return time ?? getMillisecond(getNetTimeLocal())
    }
    
    func reset() {
        timeKey = ""
        time = 0
        title = ""
        read = false
        desc = ""
        memory = false
        versionIos = 0
        createLessThan = 0
    }
}
